package com.ditri.blog.service.impl;

import com.ditri.blog.dao.UserStarBlogRouteDao;
import com.ditri.blog.entity.UserStarBlogRoute;
import com.ditri.blog.service.UserStarBlogRouteService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (UserStarBlogRoute)表服务实现类
 *
 * @author makejava
 * @since 2020-07-29 18:18:32
 */
@Service("userStarBlogRouteService")
public class UserStarBlogRouteServiceImpl implements UserStarBlogRouteService {
    @Resource
    private UserStarBlogRouteDao userStarBlogRouteDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserStarBlogRoute queryById(Long id) {
        return this.userStarBlogRouteDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UserStarBlogRoute> queryAllByLimit(int offset, int limit) {
        return this.userStarBlogRouteDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userStarBlogRoute 实例对象
     * @return 实例对象
     */
    @Override
    public UserStarBlogRoute insert(UserStarBlogRoute userStarBlogRoute) {
        this.userStarBlogRouteDao.insert(userStarBlogRoute);
        return userStarBlogRoute;
    }

    /**
     * 修改数据
     *
     * @param userStarBlogRoute 实例对象
     * @return 实例对象
     */
    @Override
    public UserStarBlogRoute update(UserStarBlogRoute userStarBlogRoute) {
        this.userStarBlogRouteDao.update(userStarBlogRoute);
        return this.queryById(userStarBlogRoute.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.userStarBlogRouteDao.deleteById(id) > 0;
    }
}